package com.ryskoo.catering.vendortemplaterel.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.vendortemplaterel.domain.VendorTemplateRelPO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

@Primary
@Repository
public class VendorTemplateRelRedisImpl extends BasicRedisImpl<VendorTemplateRelPO> implements IVendorTemplateRelRepository {

    @Autowired
    private RedisUtil redisClient;
    @Autowired
    private IVendorTemplateRelRepository vendorTemplateRelRepository;

    @PostConstruct
    public void init() {
        this.setDao(vendorTemplateRelRepository);
        this.setRedisClient(redisClient);
    }

    public VendorTemplateRelRedisImpl() {
        super(HCLCacheConstant.HCL_VENDORTEMPLATEREL_KEY);
    }

    @Override
    public void deleteByVendorUuid(String vendorUuid) {
        vendorTemplateRelRepository.deleteByVendorUuid(vendorUuid);
    }

    @Override
    public List<String> getUuidsByVendorUuid(String vendorUuid) {
        return vendorTemplateRelRepository.getUuidsByVendorUuid(vendorUuid);
    }
}